import re
from flask_restful import abort


def checkoutArgs(args):
    args_filter = dict()
    for item in args:
        if args[item] not in [None, '', 'None', '_']:
            args_filter[item] = args[item]
    return args_filter


def format_color(value):
    reg = re.compile("^#([A-Z0-9]){6}$")
    if reg.match(value) != None:
        return value
    else:
        print({"errcode": 400, "errmsg": "颜色字符传输错误"})
        abort(400, message="颜色字符传输错误")
